<?php
/*
	Aurus CMS - free OOP CMS
	Copyright (C) 2010  Nestor Yanchuk

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (! defined('ROOT')) die();
class Parser_Tag_audio extends Parser {
	public $tags_inside = true;
public $allowBr = false;
	public function get($inner,$param = ''){
		$url = urlencode(Security::cleanXSSUrl($inner));
		$id  = uniqid('mp3_');
				
		$config = 'config={
		"clip":{
			"url":"'.$url.'","autoPlay":false,"autoBuffering":false
		},
		"plugins": {
			"controls": {
				"fullscreen": false,
				"height": 30,
				"autoHide": false
			}
		},
		"playlist":[
			{"url":"'.$url.'"}
		],
		"canvas": {
			"backgroundColor":"#000"
		}
		}';
		$config = str_replace(array(R,N,"\t"),'',$config);
		
		$au = '<object width="400" height="30" id="'.$id.'" name="undefined" data="'.LINK_ROOT.'scripts/swf/flowplayer-3.2.2.swf" type="application/x-shockwave-flash">'.
		'<param name="movie" value="'.LINK_ROOT.'scripts/swf/flowplayer-3.2.2.swf" />'.
		'<param name="allowfullscreen" value="true" />'.
		'<param name="autoplay" value="false" />'.
		'<param name="flashvars" value=\''.$config.'\' /></object>';

		return '<!--audio:'.$inner.'-->'.$au.'<!--/audio-->';
	}
	
	public function unparse($text){
		return preg_replace('/\<\!--audio:(.+?)--\>.+?\<\!--\/audio--\>/is','[audio]\\1[/audio]',$text);
	}
}